﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.ComponentModel;
using Models;
using FileService;
using System.Collections.ObjectModel;
using OnTheWay.Functions;


namespace PcBackgroundMgr.Controls
{
    /// <summary>
    /// ExhibitUnitItemCtrl.xaml 的交互逻辑
    /// </summary>
    public partial class ExhibitUnitItemCtrl : FunctionCtrl
    {
        public ExhibitUnitItemCtrl()
        {
            InitializeComponent();
        }

        private void ContentControl_Loaded(object sender, RoutedEventArgs e)
        {
            ExhibitUnit model = DataContext as ExhibitUnit;
            if (model != null && model.TypeEnum == ExhibitUnitTypeEnum.视频)
            {
                Images.Add(FileFactory.GetUrl(model.MooMaUrl, FolderEnum.IMAGE));
            }
            else if (model != null && !String.IsNullOrWhiteSpace(model.UnitUrls))
            {
                string[] urls = model.UnitUrls.Split(',');
                foreach (string url in urls)
                {
                    Images.Add(FileFactory.GetUrl(url, FolderEnum.IMAGE));
                }
            }
        }

        private ObservableCollection<String> mImages = new ObservableCollection<String>();

        public ObservableCollection<String> Images
        {
            get { return mImages; }
            set { mImages = value; }
        }
    }
}
